package com.dlc.garbagerecyclebox.bean;

import android.text.TextUtils;

import java.io.Serializable;

/**
 * Created by guoshuifang on 2019/8/30.
 *  控制灯等开关时间
 */
public class ControlBean implements Serializable {
    private static final long serialVersionUID = -8565384879137011986L;

    public String openLight = "18:00";  //开灯时间 HH:mm（默认时间，18:00）
    public String offLight = "23:00";    //关灯时间（故障时不关灯）  HH:mm （默认时间，23:00）

    public double maxTemperature = 50d;//最高温度，要开风扇

    public ControlBean() {
    }

    public ControlBean(String openLight, String offLight, double maxTemperature) {
        this.openLight = openLight;
        this.offLight = offLight;
        this.maxTemperature = maxTemperature;
    }

    public String getOpenLight() {
        return TextUtils.isEmpty(openLight)? "18:00":openLight;
    }

    public String getOffLight() {
        return TextUtils.isEmpty(offLight)? "23:00":offLight;
    }

    public double getMaxTemperature() {
        return maxTemperature ==0? 50d:maxTemperature;
    }

    public boolean moreTemperature(double temperature) {
        /**
         * 允许三度的偏差值
         */
        if (temperature > getMaxTemperature() - 3) {
            return true;
        }
        return false;
    }
}
